from distutils.core import setup
from distutils.extension import Extension
import os

def pkgconfig(*packages, **kw):
	flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'}
	cmd="pkg-config --libs --cflags %s" % ' '.join(packages)
	for token in os.popen(cmd).read().split():
		kw.setdefault(flag_map.get(token[:2]), []).append(token[2:])
	return kw

pkgret=pkgconfig('gtk+-2.0 glib-2.0 gobject-2.0 pygobject-2.0 pygtk-2.0')

if not 'include_dirs' in pkgret: pkgret['include_dirs']=[]
if not 'library_dirs' in pkgret: pkgret['library_dirs']=[]
if not 'libraries' in pkgret: pkgret['libraries']=[]

setup(name='cubeass',
      version='trunk',
      author='Michal Hordecki',
      description='C backend for Cube Assistant',
      url='http://cubeassistant.googlecode.com',
      ext_modules=[
	      Extension('cubeass',sources=['cubeass.c'],include_dirs=pkgret['include_dirs'],library_dirs=pkgret['library_dirs'],libraries=pkgret['libraries']
		      )
	      ],

      )

